# ifndef __LowranceAt5_H_
# define __LowranceAt5_H_

# ifdef _MSC_VER
#	pragma pack (push, 1)
# endif

const DWORD c_dwAt5Signature = 0x0005AA55;

struct CLcmHeader {
	DWORD dwSignature;
	DWORD dwFormatVersion; // 0x00000004 for .LCM and 0x00000004 for .AT5

	DWORD dwZero;

	DWORD dwDataSize;      // Size of file data excluding header.
	DWORD dwDataCheckSum;  // Ones complement of sum of data bytes (treated as unsigned char).
	DWORD dwDataOffset;    // 0x90

	WORD  wHdrChecksum;    //
};

struct CAt5Header : public CLcmHeader {
	WORD  wHdr2Checksum;   //

	DWORD dwUnknown0;
	DWORD dwUnknown1;
	DWORD dwUnknown2;
	DWORD dwUnknown3;
};

struct CLcmHeader2 {
	//
	// Map bounds in Mercator meters.
	//
	LONG  lWest;
	LONG  lSouth;
	LONG  lEast;
	LONG  lNorth;

	//
	// Table of sections.
	//

	// ??? Small section with fixed size (36 bytes) and fixed contents for all (?) maps.
	DWORD dwSection00_Offset;
	DWORD dwSection00_HdrSize;

	// FeatureList - contains names of object types and some unknown information.
	// Contains list of map layers with it's names and links to map feature list for 5 (?) scales (?)
	DWORD dwTypes_Offset;
	DWORD dwTypes_HdrSize;

	// List of map icons with it's names and links to icon list.
	// Each icon has 5 images for various types of devices.
	DWORD dwIcons_Offset;
	DWORD dwIcons_HdrSize;

	// Zoom levels, blocks and features.
	DWORD dwBlocks_Offset;
	DWORD dwBlocks_HdrSize;

	// Seems to be list of roads.
	// May be missing (db 01)
	DWORD dwRoads_Offset;
	DWORD dwRoads_HdrSize;

	// Seems to be the index table of offsets from previous section
	DWORD dwSection05_Offset;
	DWORD dwSection05_HdrSize;
	// dw sz;
	// dd ? dup(sz/4)

	// ???
	DWORD dwSection06_Offset;
	DWORD dwSection06_HdrSize;

	// Cities names/countries ???
	DWORD dwSection07_Offset;
	DWORD dwSection07_HdrSize;

	// Unknown binary data
	DWORD dwSection08_Offset;
	DWORD dwSection08_HdrSize;

	// ???
	DWORD dwSection09_Offset;
	DWORD dwSection09_HdrSize;

	// Table of streets???
	DWORD dwStreets_Offset;
	DWORD dwStreets_HdrSize;

	// ???
	DWORD dwSection11_Offset;
	DWORD dwSection11_HdrSize;
};

struct CAt5Header2 : public CLcmHeader2 {
	DWORD dwUnknown0;

	// ???
	DWORD dwSection12_Offset;
	DWORD dwSection12_HdrSize;

	// ???
	DWORD dwSection13_Offset;
	DWORD dwSection13_HdrSize;
};

struct CAt5Icon {
	BYTE btFlags; // 0x80 - color, else mono
	WORD wWidth, wHeight;
	WORD wHotX, wHotY;
	BYTE btUnknown1; // 01 (???)
	// BYTE [wWidth*wHeight];
};

struct CAt5Block {
	BYTE bt0; // 0x01
	BYTE bt1; // 0x02
	BYTE bt2; // 0x00

	LONG lX0;
	LONG lY0;
	LONG lX1;
	LONG lY1;

	WORD wScaleFactor; // 0x003c or 0x0003 or 0x0001

	BYTE btUnknown0;
};

# ifdef _MSC_VER
#	pragma pack (pop)
# endif

# endif // __LowranceAt5_H_